{
  "properties" : { },
  "id" : "6ce7701e28684b6bb8e398db17dd2a24",
  "script" : null,
  "groupId" : "b56a24453f064cf8bf33b13a4a2a6d91",
  "name" : "运行负载导出",
  "createTime" : 1727071154729,
  "updateTime" : 1726733574297,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "runMsgExport",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : null,
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : null
}
================================
import com.kd.ndmp.core.excel.DeviceBlackListVO;
import java.net.URLEncoder;
import response;
import com.alibaba.excel.EasyExcel;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import com.kd.ndmp.core.excel.RunningLoadVO;
import cn.hutool.core.map.MapUtil;
import log

sql1 = """ select * from ndmp_device where mtnc_status = 0 """
sql = """
    select black.id, black.device_id, dev.device_name
    from ndmp_device_black_list black
    LEFT JOIN ndmp_device dev ON dev.ip = black.device_id
    <if test="ip != null and ip != ''">
        AND ip like concat('%',CAST(#{ip} AS VARCHAR),'%')
    </if>
"""

fileds = {"1","2","3","4"}
List list = new ArrayList();
if(StringUtils.isNotBlank(type)){
    listAll = new ArrayList()

    if (type == 1){
        filed = "cpuUsage"
    }else if (type == 2){
        filed = "memUsage"
    }else if (type == 3){
        filed = "delayTime"
    }else {
        filed = "packetLoss"
    }

    BigDecimal units = new BigDecimal("100");
    listDevice = db.select(sql1)
    for (v in listDevice) {
        RunningLoadVO resVo = new RunningLoadVO();
        resVo.setDeviceId(v.id);
        resVo.setDeviceName(!StringUtils.isEmpty(v.deviceAlias) ? v.deviceAlias : v.deviceName);
        resVo.setIp(v.ip);
        for (value in fileds) {
            flag = false
            if (StringUtils.equals(type, "-1")) {
                flag = true;
                type = value;
                if (type == 1){
                    filed = "cpuUsage"
                }else if (type == 2){
                    filed = "memUsage"
                }else if (type == 3){
                    filed = "delayTime"
                }else {
                    filed = "packetLoss"
                }
            }
            PointObject pointObject = StringRedisTemplateUtil.getPoint(v.id, filed);
            if (null != pointObject) {
                Map map = pointObject.getValue();
                if (!MapUtil.isEmpty(map)) {
                    BigDecimal value = new BigDecimal(map.get("0"));
                    if (type == 1){
                        resVo.setCpuUsageRate(value);
                    }else if (type == 2){
                        resVo.setMemUsageRate(value);
                    }else if (type == 3){
                        resVo.setMemUsageRate(value);
                    }else {
                        BigDecimal packetLoss = value;
                        resVo.setPacketLoss(packetLoss.multiply(units));
                    }
                }
                if (!flag) {
                    break;
                } else {
                    type = "-1";
                }
            }
        }
        listAll.add(resVo);
    }
    list = listAll;
}else{
    log.info("全量导出=================");
    ArrayList runningLoadVOS = new ArrayList();
    List listAll = new ArrayList();
    filed = "packetLoss"
    BigDecimal units = new BigDecimal("100");
    listDevice = db.select(sql1)
    for (v in listDevice) {
        RunningLoadVO resVo = new RunningLoadVO();
        resVo.setDeviceId(v.id);
        resVo.setDeviceName(!StringUtils.isEmpty(v.deviceAlias) ? v.deviceAlias : v.deviceName);
        resVo.setIp(v.ip);
        for (value in fileds) {
            flag = false
            if (StringUtils.equals(type, "-1")) {
                flag = true;
                type = value;
                filed = "packetLoss"
            }
            PointObject pointObject = StringRedisTemplateUtil.getPoint(v.id, filed);
            if (null != pointObject) {
                Map map = pointObject.getValue();
                if (!MapUtil.isEmpty(map)) {
                    BigDecimal packetLoss = new BigDecimal(map.get("0"));
                    resVo.setPacketLoss(packetLoss.multiply(units));
                }
                if (!flag) {
                    break;
                } else {
                    type = "-1";
                }
            }
        }
        listAll.add(resVo);
    }
    runningLoadVOS.addAll(listAll);
    list = runningLoadVOS;
}

var fileName = URLEncoder.encode("设备运行负载列表", "US-ASCII");
response.setHeader("content-disposition", "attachment;filename=" + fileName + ".xlsx");

response.setHeader('content-type', 'application/vnd.ms-excel;charset=UTF-8');
EasyExcel.write(response.getOutputStream(), RunningLoadVO.class).sheet("设备运行负载列表").doWrite(list);